package com.qingke.dao;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class WSessionFactory {

	private static WSessionFactory session = new WSessionFactory();
	private SqlSessionFactory factory;
	
	private WSessionFactory() {
		String config = "mybatis.xml";
		InputStream is = WSessionFactory.class.getClassLoader().getResourceAsStream(config);
		factory= new SqlSessionFactoryBuilder().build(is);
	}
	
	public static WSessionFactory getInstance() {
		return session;
	}
	
	public SqlSession getSession() {
		return factory.openSession();
	}
	
}
